package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import ezy.lite.util.DateTime;
import ezy.lite.util.UI;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.Cheap;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.IntegralDetail;

/**
 * Created by Administrator on 2016/4/26 0026.
 */
public class CheapListAdapter extends ItemAdapter<Cheap, CheapListAdapter.CheapViewHolder> {
    private Context context;

    public CheapListAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public CheapViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new CheapViewHolder(inflate(R.layout.item_cheap, parent));
    }

    @Override
    public void onBindViewHolder(CheapViewHolder holder, int position) {
        Cheap item = getItem(position);
        UI.setTvHtml(holder.txt_content,R.string.my_cheap,item.last_money,DateTime.toDate(item.time*1000));
        holder.txt_money.setText("￥"+item.money);
        switch (position){
            case 0:
                holder.rl_layout.setBackgroundResource(R.mipmap.img_youhuiquan);
                holder.txt_money.setTextColor(0xFF3DCFEB);
                break;
            case 1:
                holder.rl_layout.setBackgroundResource(R.mipmap.img_youhuiquan1);
                holder.txt_money.setTextColor(0xFF7DC4EB);
                break;
            case 2:
                holder.rl_layout.setBackgroundResource(R.mipmap.img_youhuiquan2);
                holder.txt_money.setTextColor(0xFFFF8A4F);
                break;
            case 3:
                holder.rl_layout.setBackgroundResource(R.mipmap.img_youhuiquan3);
                holder.txt_money.setTextColor(0xFF7ECA56);
                break;
            case 4:
                holder.rl_layout.setBackgroundResource(R.mipmap.img_youhuiquan4);
                holder.txt_money.setTextColor(0xFF999999);
                break;
        }
    }


    static class CheapViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_content)
        TextView txt_content;
        @BindView(R.id.txt_money)
        TextView txt_money;
        @BindView(R.id.rl_layout)
        RelativeLayout rl_layout;

        public CheapViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
//                    ContextUtil.startActivity(v.getContext(), LifeShopActivity.class);
                }
            });
        }

    }
}
